<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<style>
.bigbutton {
    display:block;
    width: 600px;
    height: 600px;
}
</style>
</head>
<body>

<button class="bigbutton">One</button>
<button class="bigbutton">Two</button>
<button class="bigbutton">Three</button>

<div id="console"></div>
<script>

async_test((t) => {
  window.scrollTo(0, 0);
  assert_equals(window.pageXOffset, 0);

  accessibilityController.addNotificationListener(t.step_func((target, notification) => {
    if (target.role == 'AXRole: AXRootWebArea' && notification == 'LayoutComplete') {
      console.log('Got notification on web area');
      accessibilityController.removeNotificationListener();
      assert_equals(window.pageYOffset, 500);
      t.done();
    }
  }));

  window.setTimeout(function() {
    window.scrollTo(0, 500);
  }, 0);

  window.setTimeout(t.step_func_done(() => {
    assert_unreached();
  }), 500);
}, "This test ensures that scrolling the window sends a notification.");

</script>

</body>
</html>
